
#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N = 2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
//判断谁大
bool cmp(vector<int>& A, vector<int>& B)
{
	if (A.size() != B.size()) return A.size() > B.size();  //直接ruturn 了就不用else

	for (int i = A.size(); i >= 0; i--)
		if (A[i] != B[i])
			return A[i] > B[i];

	return true;
}


//高精度减法
vector<int> sub(vector<int>& A, vector<int>& B)
{
	vector<int> C;
	for (int i = 0, t = 0; i < A.size(); i++)
	{
		t = A[i] - t;//某一位相减后的大小
		if (i < B.size()) t -= B[i];//判断B有没有越界
		C.push_back((t + 10) % 10);//正数+10%10相当于没变，负数+10%10相当于+10
		if (t < 0) t = 1;
		else t = 0;
	}

	while (C.size() > 1 && C.back() == 0) C.pop_back();//去掉前导0
	return C;
}
//全数不为9,让其相加为全9,开头为9让其相加为位数加一的全1
void solve()
{
	string s, ans = "";
	int n;
	sd(n);
	cin >> s;
	vector<int> a, b;
	//bool judge = true;
	if(s[0]!='9')
	{
		for (int i = 0; i < n; i++)
		{
			// if (s[i] == '9')
			// {
			// 	judge = false;
			// 	break;
			// }
			ans += ('9' - s[i])+'0';
		}
		cout << ans;
		puts("");
		return;
	}
	

	a.push_back(1);
	int sz = n;
	while (sz--)
		a.push_back(1);

	// for (int i =0; i<n; i++)
	// 	b.push_back(s[i] -'0');

	for(int i=n-1;i>=0;i--)
		b.push_back(s[i]-'0');

	vector<int> ans2 = sub(a, b);

	//for(auto&k:ans2) pd(k);
	for (int i = ans2.size() - 1; i >= 0; i--) pd(ans2[i]);
	puts("");




}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}